package com.ruoyi.chat.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    @Value("${mq.CHAT_TOPIC}")
    public String chatTopic;
    @Value("${mq.CHAT_ACK_TOPIC}")
    public String chatAckTopic;
    @Value("${mq.CHAT_EXCHANGE}")
    public String chatExchange;
    @Value("${mq.CHAT_ACK_EXCHANGE}")
    public String chatAckExchange;
    @Bean
    public Queue chatQueue(){
        return new Queue(chatTopic);
    }
    @Bean
    public Queue chatQueue2(){
        return new Queue(chatAckTopic);
    }
    @Bean
    public TopicExchange exchange(){
        return new TopicExchange(chatExchange);
    }
    @Bean
    public TopicExchange exchange2(){
        return new TopicExchange(chatAckExchange);
    }
    @Bean
    public Binding bindChatTopicToChatExchange(){
        return BindingBuilder.bind(chatQueue()).to(exchange()).with(chatTopic);
    }
    @Bean
    public Binding bindChatTopicToChatExchange2(){
        return BindingBuilder.bind(chatQueue2()).to(exchange()).with(chatAckTopic);
    }
}
